package com.sl.core.engine.listener;

import com.sl.core.engine.domain.ProcessRowEvent;
import com.sl.core.engine.log.ProcessLogChannel;
import org.apache.hop.core.logging.ILogChannel;

public class ProcessRowLogListener implements RowListener {

    public static final ProcessRowLogListener INSTANCE = new ProcessRowLogListener();


    @Override
    public void start(ProcessRowEvent processRowEvent) {

    }

    @Override
    public void input(ProcessRowEvent processRowEvent) {
        Object input = processRowEvent.getInput();
        ILogChannel logChannel = processRowEvent.getLogChannel();
        if (logChannel instanceof ProcessLogChannel processLogChannel) {
            processLogChannel.logInput(input);
        }
    }

    @Override
    public void process(ProcessRowEvent processRowEvent) {

    }

    @Override
    public void output(ProcessRowEvent processRowEvent) {
        ILogChannel logChannel = processRowEvent.getLogChannel();
        Object output = processRowEvent.getOutput();
        if (logChannel instanceof ProcessLogChannel processLogChannel) {
            processLogChannel.logOutput(output);
        }
    }

    @Override
    public void end(ProcessRowEvent processRowEvent) {

    }

    @Override
    public void error(ProcessRowEvent processRowEvent) {

    }
}
